UDL Class

Overview

_images/Layer.png

GridLayer

class GridLayer(name, start_lat, end_lat, start_lon, end_lon, step_lat,
    step_lon, year=None)
PARAMETERS:
  • name (string) - Name of the layer

  • start_lat (float) - Starting latitude

  • end_lat (float) - Ending latitude

  • start_lon (float) - Starting lontitude

  • end_lon (float) - Ending lontitude

  • step_lat (float) - The difference of latitude between cells

  • step_lon (float) - The difference of lontitude between cells

  • year (int) - The year of dataset

construct_grid (data)

PARAMETERS:

  • data (numpy.array) - The data of GridLayer

get_value (lat, lon):

PARAMETERS:

  • lat (float) - Latitude to be queried

  • lon (float) - Longitude to be queried

RETURNS:

  • value (float) - Value at the queried location

get_value_by_grid (lat, lon):

PARAMETERS:

  • lat (numpy.array) - Latitudes to be queried in an array of one dimension

  • lon (numpy.array) - Longitudes to be queried in an array of one dimension

RETURNS:

  • value (numpy.array) - Values at the queried locations in an array of one dimension

GraphLayer

class GraphLayer(name, year=None, directed=False)

Note

The methods of NetworkX are also available for the GraphLayer’s data object (GraphLayer.data).

PARAMETERS:
  • name (string) - Name of the layer

  • year (int) - The year of the dataset

  • directed (bool) - Whether the graph is directed

construct_node (node_label, latitude, longitude, node_attribute=None)

PARAMETERS:

  • node_label (list) - The list of the name of node

  • latitude (list[float]) - The list of the latitude of node

  • longitude (list[float]) - The list of the longitude of node

  • node_attribute (list) - The list of the attribute (whose name is layer’s name) values of node (optional)

RETURNS:

  • node_list (list[tuple]) - The list of the tuple which can be used to construct the graph nodes

construct_edge (source: list, target: list, edge_attribute=None, edge_weight=None)

PARAMETERS:

  • source (list) - The list of the source nodes of each edge

  • target (list) - The list of the target nodes of each edge

  • edge_attribute (string) - The attribute name of edge (optional)

  • edge_weight (list[float]) - The list of the weight of edge (optional)

RETURNS:

  • edge_list (list[tuple]) - The list of the tuple which can be used to construct the graph egdes

construct_graph (node_label, latitude, longitude, source: list, target: list, node_attribute=None, edge_attribute=None, edge_weight=None)

PARAMETERS:

  • node_label (list) - The list of the name of node

  • latitude (list[float]) - The list of the latitude of node

  • longitude (list[float]) - The list of the longitude of node

  • source (list) - The list of the source nodes of each edge

  • target (list) - The list of the target nodes of each edge

  • node_attribute (list[string]) - The list of the attribute (whose name is layer’s name) values of node (optional)

  • edge_attribute (string) - The attribute name of edge (optional)

  • edge_weight (list[float]) - The list of the weight of edge (optional)

RETURNS:

  • graph (GraphLayer) - The graph data in the form of GraphLayer

PointLayer

class PointLayer(name, year=None, column_list=None)

Note

The methods of pandas.DataFrame are also available for the PointLayer’s data object (PointLayer.data).

PARAMETERS:
  • name (string) - Name of the layer

  • year (int) - The year of the dataset

  • column_list (list[string]) - The list of the attribute names of the point data

add_points (data_df)

PARAMETERS:

  • data_df (pandas.DataFrame) - The dataframe of the point data

delete_point (lat, lon)

PARAMETERS:

  • lat (float) - Latitude of the point to be deleted

  • lon (float) - Longitude of the point to be deleted

get_value (lat, lon, feature_name=None)

PARAMETERS:

  • lat (float) - Latitude of the point to be queried

  • lon (float) - Longitude of the point to be queried

  • feature_name (list[string]) - The attribute name of the point data to be queried (optional)

RETURNS:

  • value (numpy.array) - Value at the queried location

get_value_by_range (start_lat, end_lat, start_lon, end_lon, feature_name=None)

PARAMETERS:

  • start_lat (float) - Starting latitude of the range to be queried

  • end_lat (float) - Ending latitude of the range to be queried

  • start_lon (float) - Starting longitude of the range to be queried

  • end_lon (float) - Ending longitude of the range to be queried

  • feature_name (list[string]) - The attribute name of the point data to be queried (optional)

RETURNS:

  • value (numpy.array) - Value at the queried location

to_gpd ()

RETURNS:

  • data (geopandas.GeoDataFrame) - The geopandas dataframe of the point data

LinestringLayer

class LinestringLayer(name, file=None, year=None, column_list=[])

Note

The methods of geopandas.GeoDataFrame are also available for the LinestringLayer’s data object (LinestringLayer.data).

PARAMETERS:
  • name (string) - Name of the layer

  • file (string) - The path of the file (the file can be read by geopandas, e.g. shapefile and GeoJson) which contains the linestring data. If the file is not given, the linestring data will be empty.

  • year (int) - The year of the dataset

  • column_list (list[string]) - The list of the attribute names of the linestring data

add_polygons (data_gdf)

PARAMETERS:

  • data_gdf (geopandas.GeoDataFrame) - The geopandas dataframe of the linestring data to be added

PolygonLayer

class PolygonLayer(name, file=None, year=None, column_list=[])

Note

The methods of geopandas.GeoDataFrame are also available for the PolygonLayer’s data object (PolygonLayer.data).

PARAMETERS:
  • name (string) - Name of the layer

  • file (string) - The path of the file (the file can be read by geopandas, e.g. shapefile and GeoJson) which contains the polygon data. If the file is not given, the polygon data will be empty.

  • year (int) - The year of the dataset

  • column_list (list[string]) - The list of the attribute names of the polygon data

add_polygons (data_gdf)

PARAMETERS:

  • data_gdf (geopandas.GeoDataFrame) - The geopandas dataframe of the polygon data to be added